#!/usr/bin/env node
const { getAccessToken, jsonOfResponse } = require('./index.js')
const https = require('https')

function listgtorgs() {
    var url = "https://gitee.com/api/v5/user/orgs" + "?access_token=" + getAccessToken()
    
    https.request( url, {
        method: "GET"
    }, ( res ) => {
        jsonOfResponse( res, ( json ) => {
            for ( var i = 0; i <= json.length - 1; i++ ) {
                console.log( "[" + ( i + 1 ) + "] https://gitee.com/" + json[ i ].login )
            }
        } )
    } ).on( 'error', ( error ) => {
        console.log( "error: ", error )
    } ).end();
}

listgtorgs()
